<!DOCTYPE html>
<html lang="en">
<include file="CommonSidebar:common-head"/>
<link rel="stylesheet" href="__ROOT__/Application/Admin/Public/css/common.css">
<link href="__ROOT__/Application/Admin/Public/css/jquery.datetimepicker.css" rel="stylesheet">
<body>

<div id="wrapper">

    <!-- Navigation -->
    <include file="CommonSidebar:common-navbar"/>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">横幅管理</h1>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
        <div class="row">
            <div class="col-lg-12">
                <a href="{:U('addPic')}" class='btn btn-default'>新建{$banner_name}</a>

                <h1></h1>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        {$banner_name}
                    </div>
                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        <div class="dataTable_wrapper">
                            <table class="table table-striped table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th style="text-align:center" width="30%">图片</th>
                                    <th style="text-align:center" >图片标题</th>
                                    <th style="text-align:center" width="30%">跳转链接</th>
                                    <th style="text-align:center">排序</th>
                                    <th style="text-align:center">图片类型</th>
                                    <th style="text-align:center">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <foreach name="LBDATA" item="v" key="k">
                                    <tr class="odd gradeX">
                                        <td><img width="100px" src="{$v.banner_img}"/></td>
                                        <td>{$v.banner_title}</td>
                                        <td style="vertical-align:middle;"><a href="{$v.banner_url}"
                                                                              target="_blank">{$v.banner_url}</a></td>
                                        <td style="vertical-align:middle;">{$v.banner_number}</td>

                                        <if condition="$v.banner_url_type == 4">
                                            <td style="vertical-align:middle;">轮播图</td>
                                            <else/>
                                            <td style="vertical-align:middle;">主题书单</td>
                                        </if>
                                        <td style="vertical-align:middle;">
                                            <a href="{:U('addPic')}?banner_id={$v.banner_id}"
                                               class="btn btn-warning btn-xs"
                                               title="Edit">编辑</a>
                                            <a href="javascript:void(0)" onclick="DeleteTar('{$v.banner_id}',$(this))"
                                               class="btn btn-danger btn-xs" title="Delete">删除</a>
                                            <if condition="$v.banner_url_type == 1">
                                                <a href="{:U('BookList/Index')}?banner_id={$v.banner_id}"
                                                   class="btn btn-warning btn-xs" title="ck">查看书单</a>
                                            </if>
                                        </td>

                                    </tr>
                                </foreach>
                                </tbody>
                            </table>
                        </div>
                        <!-- /.table-responsive -->
                    </div>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
            <!-- /.col-lg-12 -->
        </div>
    </div>
    <!-- /#page-wrapper -->

</div>
<!-- /#wrapper -->


<!--裁剪与上传-->
<include file="CommonSidebar:common-script"/>
<script src="__ROOT__/Application/Admin/Public/js/jquery.datetimepicker.js"></script>
<!-- DataTables JavaScript -->
<script src="__ROOT__/Application/Admin/Public/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
<script src="__ROOT__/Application/Admin/Public/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>

<!-- Custom Theme JavaScript -->
<script src="__ROOT__/Application/Admin/Public/dist/js/sb-admin-2.js"></script>
<!-- Page-Level Demo Scripts - Tables - Use for reference -->


<script type="text/javascript" src="__ROOT__/Application/Admin/Public/LoadPading/LoadPading.js?v=3"></script>
<link rel="stylesheet" href="__ROOT__/Application/Admin/Public/LoadPading/LoadPading.css" type="text/css"
      media="screen"/>
<script type="text/javascript">
    function DeleteTar(ID, elem) {
        if (confirm("确认删除？")) {
            $.post("{:U('Del')}",
                    {ID: ID},
                    function (data) {
                        if (data) {
                            alert('删除成功');
                            elem.parent().parent().remove();
                        } else {
                            alert('删除失败');
                        }
                    });
        }
    }
</script>
<script>
    $(function () {
        new CropAvatar({
            container: '#crop-avatar',
            workspaces: '/Train/',
            formUrl: "{:U('Pic/changeTX')}",
            submitDone: function (data) {
                var $avatarView = $('.avatar-view');
                if (data.state == 1) {
                    var imgUrl = data.picpath;
                    var imgUrlTH = data.data;

                    var html = ' <div class="goods-img-item">';
                    html += '<img style="max-height: 80px" src="' + '__ROOT__/' + imgUrl + '" alt="">';
                    html += '<span class="glyphicon close-goods-img glyphicon-remove-circle"></span>';
                    html += '</div>';

                    $avatarView.before(html);
                    $avatarView.siblings("input[name='picpath']").val(imgUrl);
                    $avatarView.siblings("input[name='thumbpicpath']").val(imgUrlTH);
                    $avatarView.hide();

                    $avatarView.parents(".form-group").removeClass("has-error").addClass("has-success");
                    $avatarView.parents(".form-group").find(".help-block").hide();

                    $('#crop-avatar').find('#avatar-modal').modal('hide');
                } else {
                    alert('Failed to response');
                }
            },
            delete: function (e) {
                var _this = e.target;
                var flag = _this.className.indexOf('close-goods-img');
                var $avatarView = $('.avatar-view');
                if (flag >= 0) {
                    var $elem = $(_this);
                    if (confirm("确认移除？")) {
                        $avatarView.show();
                        $elem.parent(".goods-img-item").remove();
                        $avatarView.next("input[name='thumbpicpath']").val("");
                        $avatarView.next("input[name='picpath']").val("");
                        $('.add-goods-img').attr('src', '__PUBLIC__/Boss/images/default.png')
                    }
                }
            }

        });
    });

    function submitcheck() {
        var $picid = $("input[name='picid']");
        if ($picid.val() == "") {
            $picid.parents(".form-group").removeClass("has-success").addClass("has-error");
            $picid.parents(".form-group").find(".help-block").show();
            return false;
        }
    }
</script>
</body>
</html>
